<template>
<view>
	<view class="header">总业绩:{{count}}</view>
	<view class="top">
		<view @click="select(1)" class="header_select border_right" :class="type == 1 ? 'border-bottom' : ''">充值业绩</view>
		<view @click="select(2)" class="header_select border_right" :class="type == 2 ? 'border-bottom' : ''">开卡业绩</view>
		<view @click="select(3)" class="header_select border_right" :class="type == 3 ? 'border-bottom' : ''">购买业绩</view>
		<view @click="select(4)" class="header_select" :class="type == 4 ? 'border-bottom' : ''">手工业绩</view>
	</view>
	<view class="table">
		<table border="0" width="95%" cellspacing="0" cellpadding="0">
			<tr>
				<td>业绩合计:</td>
				<td colspan="2">{{money}}</td>
			</tr>
			<tr>
				<td>员工姓名</td>
				<td>分成业绩</td>
			</tr>
			<tr v-for="(item,index) in list" :key="index">
				<td>{{item.user_name}}</td>
				<td>{{item.money}}</td>
			</tr>
		</table>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			//oaRole 1:店长2:员工3:商户
			oaRole:0,
			type:1,
			list:[],
			money:'0.00',
			count:'',
			page:1,
			pageShow:true,
		}
	},
	onLoad:function(){
		uni.showLoading({
		    title: '加载中'  
		});
		this.getList()
		this.oaRole = uni.getStorageSync('oaRole')
	},
	methods: {
		getList:function(){
			var data = {
				type:this.type,
				page:this.page
			}
			if(uni.getStorageSync('oaRole') == 2){
				data.uid = uni.getStorageSync('uid')
			}else{
				data.oa_id = uni.getStorageSync('oa_id')
			}
			var that = this
			request({
				url: 'manage/my/info',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading()
					that.money = res.data.data.money
					if(res.data.code == 1){
						if(res.data.data.last_page <= that.page){
							that.pageShow = false
						}
						if(that.page == 1){
							that.list = res.data.data.list.data
						}else{
					        var list = that.list
					        that.list = list.concat(res.data.data.list.data)
					    }
					}
				},
			})
		},
		select:function(key){
			this.type = key
			uni.showLoading({
			    title: '加载中'  
			});
			this.getList()
		},
		onReachBottom: function(){
			if(this.pageShow){
				 //当前不是最后一页可加载
				 this.page = this.page + 1
				 uni.showLoading()
				 this.getList();
			}
		},
	},
}
</script>
<style>
@import url("./index.css");
</style>